
"use client"

import { UseAppSelector } from "@/hooks/hook";
import { selectLoginStatus } from "@/redux/loginStore";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { logout } from "@/redux/loginStore";
import { UseAppDispatch } from "@/hooks/hook";

const DahsBoard:React.FC = function() {
    const status = UseAppSelector(selectLoginStatus);
    const router = useRouter();
    const dispatch = UseAppDispatch();
    useEffect(() => {
      if (!status) {
        router.push("/");
      }
    },[router, status])
    // console.log(111)
    return (
      <>
       <button onClick={() => {dispatch(logout());router.push("/")}}>登出</button>
      </>
    );
  }

  export default DahsBoard
  